%% Based on a TeXnicCenter-Template by Tino Weinkauf.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HEADER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[fleqn,a4paper,twoside,11pt]{article}

% Alternative Options:
%	Paper Size: a4paper / a5paper / b5paper / letterpaper / legalpaper / executivepaper
% Duplex: oneside / twoside
% Base Font Size: 10pt / 11pt / 12pt

%% Language %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage[USenglish]{babel} %francais, polish, spanish, ...
\usepackage[T1]{fontenc}

%\usepackage[ansinew]{inputenc}
\usepackage[utf8]{inputenc}	%supports Umlaute
\usepackage{german, ngerman}
\usepackage{color}
\usepackage{listingsutf8}

\usepackage{lmodern} %Type1-font for non-english texts and characters

%% Packages for Graphics & Figures %%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx} %%For loading graphic files
\usepackage{multicol}

%% Math Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}


%% Line Spacing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{setspace}
%\singlespacing        %% 1-spacing (default)
%\onehalfspacing       %% 1,5-spacing
%\doublespacing        %% 2-spacing
\setlength{\parindent}{0pt} %kein Einzug beim Absatzbegin

%% Other Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{a4wide} %%Smaller margins = more text per page.
\usepackage{fancyhdr} %%Fancy headings

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=0.5pt](char) {#1};}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\pagestyle{fancyplain}
%\pagestyle{fancy} %Now display headings: headings / fancy / ...
%\pagestyle{empty} %No headings for the first pages.

%% Title Page %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Meilenstein 1 - Compilerbau} 
\author{Mathias Tempel - 343290,\\ Richard Klemm - 343635,\\ Hannes Rammer - 335371\\Gruppe G15}
\date{Abgabe: Sonntag, 11. Dezember 2011} %%If commented, the current date is used.
\maketitle

%% Header on top of every page (yes, also on the 
\rhead{Compilerbau 1 - Meilenstein 1 - TU Berlin, WS2011/12}
\lhead{}
\renewcommand{\headrulewidth}{0px}

\section{Aufgabe 1 - Parser}
\subsection*{a)}
	\begin{equation*}
		Prog \rightarrow \hspace{4pt}^{\circled{1}} Def\hspace{4pt}Def^`\hspace{4pt}\# \hspace{4pt}^{\circled{2}}
	\end{equation*}
	\begin{equation*}
		Def^` \rightarrow Def\hspace{4pt}Def^`\hspace{4pt}|\hspace{4pt}\epsilon
	\end{equation*}
	\begin{equation*}
		Def \rightarrow \underline{DEF}\hspace{4pt}Lhs\hspace{4pt} \underline{==}\hspace{4pt}Expr \hspace{4pt}^{\circled{3}}
	\end{equation*}
	\begin{equation*}
		Lhs \rightarrow \underline{MAIN}\hspace{4pt}\underline{:}\hspace{4pt}Type\hspace{4pt} ^{\circled{4}}\hspace{4pt}
	\end{equation*}
	\begin{equation*}
		\hspace{40pt}|\hspace{4pt}\underline{id}\hspace{4pt}^{\circled{1}}\hspace{4pt}params\hspace{4pt}
		\underline{:}\hspace{4pt}Type\hspace{4pt}^{\circled{5}}
	\end{equation*}
	\begin{equation*}
		params \rightarrow \underline{(}\hspace{4pt}paramlist\hspace{4pt}\underline{)}
		 \hspace{4pt} | \hspace{4pt}\epsilon 
	\end{equation*}
	\begin{equation*}
		paramlist \rightarrow \hspace{4pt} param \hspace{4pt} nextparam\hspace{4pt}
		| \hspace{4pt}\epsilon 
	\end{equation*}
	\begin{equation*}
	nextparam \rightarrow \hspace{4pt} \underline{,}\hspace{4pt}param\hspace{4pt}nextparam
	 \hspace{4pt} | \hspace{4pt}\epsilon 
	\end{equation*}
	\begin{equation*}
	param \rightarrow\hspace{4pt}\underline{id}\hspace{4pt}\underline{:}
	\hspace{4pt}Type\hspace{4pt}^{\circled{6}}
	\end{equation*}
	\begin{equation*}
		Type \rightarrow \underline{nat}\hspace{4pt}^{\circled{7}}
			 \hspace{4pt} |\hspace{4pt}\underline{bool}\hspace{4pt}^{\circled{7}}
	\end{equation*}
	\begin{equation*}
	Expr \rightarrow \underline{number}\hspace{4pt}^{\circled{8}}
	\end{equation*}
	\begin{equation*}
		\hspace{40pt}| \hspace{4pt}\underline{true}\hspace{4pt}^{\circled{9}}\hspace{4pt}
	\end{equation*}
	\begin{equation*}
	\hspace{40pt}|\underline{false}\hspace{4pt}^{\circled{10}}\hspace{4pt}
	\end{equation*}
	\begin{equation*}
	\hspace{40pt}|\hspace{4pt}FunCall\hspace{4pt}
	\end{equation*}
	\begin{equation*}
	\hspace{40pt}|\hspace{4pt}\underline{IF}\hspace{4pt}Expr\hspace{4pt}\underline{THEN}\hspace{4pt}Expr\hspace{4pt}^{\circled{11}}\hspace{4pt}OptElse\hspace{4pt}\underline{FI}
	\end{equation*}
	\begin{equation*}
		OptElse \rightarrow \underline{ELSE}\hspace{4pt}Expr\hspace{4pt}^{\circled{12}}
			\hspace{4pt}| \hspace{4pt}\epsilon
	\end{equation*}
	\begin{equation*}
	NextExpr \rightarrow \underline{,}\hspace{4pt}Expr\hspace{4pt}^{\circled{13}}
	\hspace{4pt}NextExpr \hspace{4pt}|\hspace{4pt}\epsilon
	\end{equation*}
	\begin{equation*}
		FunCall \rightarrow \underline{id}\hspace{4pt}
		^{\circled{1}}\hspace{4pt}
		FunCallParams
		\hspace{4pt}^{\circled{14}}
	\end{equation*}
	\begin{equation*}
	FunCallParams \rightarrow \underline{(}FunParam\underline{)} \hspace{4pt}|\hspace{4pt}\epsilon
	\end{equation*}
	\begin{equation*}
	FunParam \rightarrow
	\hspace{4pt}Expr\hspace{4pt}^{\circled{13}}\hspace{4pt}
	NextExpr 
	\hspace{4pt}| \hspace{4pt}\epsilon
	\end{equation*}
	
\newpage

\circled{1} $\rightarrow $ makeEmptyAbsySeq\\
\circled{2} $\rightarrow $ makeProg \\
\circled{3} $\rightarrow $ makeDef \\
\circled{4} $\rightarrow $ makeMainDec \\
\circled{5} $\rightarrow $ makeFunDec \\
\circled{6} $\rightarrow $ makeParam \\
\circled{7} $\rightarrow $ makeType \\
\circled{8} $\rightarrow $ makeNumber \\
\circled{9} $\rightarrow $ makeTrue \\
\circled{10} $\rightarrow $ makeFalse \\
\circled{11} $\rightarrow $ makeIfThen \\
\circled{12} $\rightarrow $ makeIfThenElse \\
\circled{13} $\rightarrow $ makeExprList \\
\circled{14} $\rightarrow $ makeFunCall \\

\subsection*{b)}
\lstset{language=erlang,breaklines=true,inputencoding=utf8/latin1,morekeywords={SIGNATURE, IMPORT, ONLY, TYPE, absy, seq}}
\lstinputlisting{AbsyReport.sign}
\end{document}

